import http from '@/util/http'

const module = {
  namespaced: true, // 命名空间
  state: {
    tabList: [],
    subNavShow: false
  },
  actions: {
    getTabAction (store) {
      http.request({
        url: '/api/tabs?sa='
      }).then(res => {
        console.log('tab', res.data)
        store.commit('setTabList', res.data.data.list) // 支持传参
        // this.arealist =......
      })
    }

  },
  mutations: {
    setTabList (state, data) {
      console.log('setTabList', data)
      state.tabList = data
    },
    setShow (state) {
      console.log('show')
      state.subNavShow = true
    },
    setHide (state) {
      console.log('hide')
      state.subNavShow = false
    }
  },
  getters: {
    topDataOne (state) {
      // state形参s， vuex自动调用时候，传来值
      return state.tabList.slice(0, 1)[0]
    },
    topDataEnd (state) {
      // state形参s， vuex自动调用时候，传来值
      return state.tabList.slice(1)
    }
  }
}

export default module
